<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% String path = request.getContextPath();%>
    	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    	<title>修改密码</title>
<jsp:include page="/web/manager/inc/header.jsp"></jsp:include>

			
                <div class="add_Test main_container">
                	<div class="row page-titles mx-0">
                        <div class="col-sm-6 p-md-0">
                            <div class="welcome-text">
                                <h4 class="text-primary">修改密码</h4>
                                <p class="mb-0">Update Password</p>
                            </div>
                        </div>
                       
                    </div>
				</div>
				
		        <div class="row">
                        <div class="col-md-12">
                            <div class="card shadow mb-4">
                                <div class="card-header" id="alarm">
                                    <h4 class="card-title">编辑密码</h4>
                                </div>
                                <div class="card-body">
                                    <div class="basic-form">
                                        <form id="passform" action="<%=path %>/ManagerController?action=changePass" method="post" enctype="multipart/form-data">
                                            <div class="row">
                                             <div class="col-xl-12">
                                                    <div class="form-group" id="previous">
                                                       <span>原密码</span>
                                                        <input id="pre" name="" type="password" class="form-control" placeholder="请输入原密码，密码正确执行修改操作" />
                                                        <button type="button" id="checkPass" class="btn btn-primary">确定</button>
                                                    </div>
                                                </div> 
                                                <div class="col-xl-12">
                                                    <div class="form-group" id="one">
                                                       <span>新密码</span>
                                                        <input  id="first" name="newPass" type="password" class="form-control" placeholder="" />
                                                    </div>
                                                </div>
                                                <div class="col-xl-12">
                                                    <div class="form-group" id="two">
                                                       <span>确认密码</span>
                                                       <input id="second" name="" type="password" class="form-control" placeholder="" />
                                                        
                                                    </div>
                                                </div>
                                                
                                                <div class="col-xl-12">
                                                    <div class="form-group">
                                                        <button  class="btn btn-primary float-end">保存</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>   
		<script>
		var check1 = false;
		var check2 = false;
		var path="${pageContext.request.contextPath}"		
			 $(function(){
				 $("#first").attr("disabled","disabled");
				$("#second").attr("disabled","disabled");
				$("#checkPass").on("click",function(){
					var prePass = $("#pre").val();
					$.post(path+"/ManagerController?action=checkPrePass&prePass="+prePass,function(data){
						if(data==1){
							 $("#first").removeAttr("disabled");
							$("#second").removeAttr("disabled");
							$("#checkPass").attr("disabled","disabled");
						}
						else{
							alert("原密码错误，请重新输入")
						}
					})
				})
				
			 
				$("#first").blur(function(){
					if($("#first").val()==""){
						$("#one p").remove();
						$("#one").append("<P>请输入新密码</p>");
					}
					else{
						$("#one p").remove();
						check1=true;
						
					}
				})
				$("#second").blur(function(){
					if($("#first").val()!=$("#second").val()){
						$("#two p").remove();
						$("#two").append("<P>两次输入不一致，请重新输入确认密码</p>")
					}
					else{
						$("#two p").remove()
						check2=true;
					}
				})
				$("#passform").submit(function(){
					if(!(check1&&check2)){
						$("#alarm h3").remove();
						$("#alarm").append("<h3 style='color'>!输入密码有误，无法提交</h3>")
						} 
					return (check1&&check2);
				})
			}) 
			
		</script>



  <jsp:include page="/web/manager/inc/footer.jsp"></jsp:include>